[LaTeX] 关于图片环绕

在$\LaTeX$ 插入图片时, 还有一种情况会非常讨厌, 就是图片环绕。正常写论文报告还好,基本上图文是分离的,然而如果尝试过用LaTeX写assignment, 在每一道题旁边都要插图的话, 设置环绕就非常必要了。不多说废话,接下来是代码:

1
2
3
4
5
6
7
8
9
\documentclass[letterpaper,10pt]{article}
\usepackage{wrapfig}
\usepackage{graphicx}
\begin{document}
\begin{wrapfigure}{l}{0.4\textwidth}
\includegraphics[width=0.25\textheight]{a.png}
\end{wrap figure}
Lorem ipsum dolor sit amet, ligula suspendisse nulla pretium, rhoncus tempor fermentum, enim integer ad vestibulum volutpat. Nisl rhoncus turpis est, vel elit, congue wisi enim nunc ultricies sit, magna tincidunt.
\end{document}

几个要注意的方面: 1. 使用wrapfigure 需要 wrapfig 宏包 2. 注意warpfigure 有两个参数, 第一个参数选择“l”是靠左,选择“r”是靠右。 第二个参数是宽度,既可以设定绝对宽度也可以设定相对于页面的宽度,注意使用绝对宽度的时候带好单位。3. 插入图片时还有一个参数,用来调整图片的大小, 最好wrapfigure 的参数略大于图片的参数, 不然图片会和文字重叠。 4. 是wrapfigure 不是 warpfigure, 宏包同理。 不需要的自动无视此条, 反正我自己手打的时候就没打对过。

Reference:
https://cn.sharelatex.com/learn/Inserting_Images